<template>
  <div class="all">
    <header>
      <div class="div">
        <img src="../../../assets/返回.png" @click="back()" alt="">
        <span class="solid" @click="back()">返回</span>
      </div>
      <div class="div">
        <span>服务消息</span>
      </div>
      <div class="div">
        <span class="solid"></span>
      </div>
    </header>
    <div class="box">
      <div class="top">{{item.title}}</div>
      <div class="content">{{item.content}}</div>
      <div class="bottom">{{formatDate(item.time)}}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ServiceDetails',
  computed: {
    item: function () {
      return JSON.parse(sessionStorage.getItem('serviceMessage'))
    }
  },
  methods: {
    formatDate (date) {
      var date = new Date(date)

      var YY = date.getFullYear() + '-'

      var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'

      var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate())

      var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'

      var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'

      var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())

      return YY + MM + DD + ' ' + hh + mm + ss
    },
    back () {
      this.$router.history.go(-1)
    }
  },
  destroyed () {
    sessionStorage.removeItem('serviceMessage')
  }
}
</script>

<style scoped>
  .all{
    width: 100%;
    height: 100%;
    background: #FAF9FE;
    overflow: auto;
  }
  header{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #E5E5E5;
    background: white;
    position: sticky;
    top: 0;
    z-index: 9;
  }
  .div{
    width: 33%;
    height: 100%;
    display: flex;
    align-items: center;
    font-family: "PingFang SC";
    font-size: 15px;
    font-weight: bold;
  }
  .div img{
    margin-right: 5px;
  }
  .div:nth-child(1) img{
    height: 13px;
    width: 7px;
    margin-left: 15px;
  }
  .div:nth-child(3) img{
    margin-right: 5px;
  }
  .div:nth-child(3) span{
    margin-right: 15px;
  }
  .div:nth-child(2){
    justify-content: center;
  }
  .div:nth-child(3){
    justify-content: flex-end;
  }
  .solid{
    color: #1DA4F2;
  }
  .box{
    width: 95%;
    padding: 10px;
    box-sizing: border-box;
    box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    margin: 10px auto auto auto;
    display: flex;
    flex-direction: column;
    background: white;
  }
  .top{
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: bold;
    color: #333333;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .content{
    font-family: PingFang SC;
    font-weight: 500;
    color: #666666;
    font-size: 13px;
    padding: 8px 0;
    box-sizing: border-box;
  }
  .bottom{
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #999999;
    display: flex;
    justify-content: flex-end;
  }
</style>
